import Transaction
class transactionPool:
    transaction_list = []
    max_length = 4

    def add_into_pool(self,transaction_input):
        if(len(self.transaction_list) >= self.max_length):
            return False
        else:
            i=0
            while i<len(self.transaction_list):# 交易去重
                if(self.transaction_list[i].Nounce == transaction_input.Nounce):
                    return False
                i=i+1
            self.transaction_list.append(transaction_input)
            return True

    def delete_from_pool(self,i):
        if(len(self.transaction_list)<i | i<=0):
            return False
        del self.transaction_list[i-1]
        return True

    def delete_all(self):
        self.transaction_list.clear()
